//
//  BIDRentConditionListViewController.m
//  HJGJCommunity
//
//  Created by mal on 2017/6/15.
//  Copyright © 2017年 mal. All rights reserved.
//

#import "BIDRentConditionListViewController.h"

@interface BIDRentConditionListViewController ()

@end

@implementation BIDRentConditionListViewController
@synthesize delegate;
@synthesize selectedIndexPath;
@synthesize dataSourceArr;
@synthesize selectedItemID;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"出租";
    self.tableView.tableFooterView = [[UIView alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source


#pragma mark - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataSourceArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    static NSString *identifier = @"identifier";
    NSUInteger row = indexPath.row;
    cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if(!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    NSDictionary *dic = self.dataSourceArr[row];
    cell.textLabel.text = dic[@"name"];
    if([selectedItemID isEqualToString:dic[@"value"]])
    {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }
    else
    {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSUInteger row = indexPath.row;
    NSDictionary *dic = dataSourceArr[row];
    [delegate getConditionText:dic[@"name"] itemID:dic[@"value"] atIndexPath:selectedIndexPath];
    [self.navigationController popViewControllerAnimated:YES];
}

@end
